﻿
Imports System
Imports System.Windows
Imports GeoCoordinateConverter

Public Class MainWindow
    Private Sub btnConvert_Click(sender As Object, e As RoutedEventArgs)



        Try
            ' 获取用户输入的纬度和经度的度分秒
            Dim latDegrees As Double = Double.Parse(txtLatitudeDegrees.Text)
            Dim latMinutes As Double = Double.Parse(txtLatitudeMinutes.Text)
            Dim latSeconds As Double = Double.Parse(txtLatitudeSeconds.Text)
            Dim lonDegrees As Double = Double.Parse(txtLongitudeDegrees.Text)
            Dim lonMinutes As Double = Double.Parse(txtLongitudeMinutes.Text)
            Dim lonSeconds As Double = Double.Parse(txtLongitudeSeconds.Text)

            ' 将度分秒转换为十进制度
            Dim latitude As Double = latDegrees + latMinutes / 60 + latSeconds / 3600
            Dim longitude As Double = lonDegrees + lonMinutes / 60 + lonSeconds / 3600

            Dim zoneWidth As Integer = If(cmbZoneWidth.SelectedIndex = 0, 3, 6)

            Dim GR As New GaussCoord()
            Dim GP As New GaussProjection()

            ' 调用高斯正算函数
            GR = GP.GaussProjectionCal(latitude, longitude, 0)

            ' 显示结果
            lblResult.Text = $"带号: {GR.ZoneNumber },  中央经线: { GR.CentralMeridian }°,  高斯投影坐标: X={GR.Northing.ToString("F3")},   Y={GR.Northing.ToString("F3")}"
        Catch ex As Exception
            MessageBox.Show($"输入错误: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error)
        End Try
    End Sub

End Class

